﻿<style>
    .success-file p {
        font-size: 22px;
        color: #1bad28;
    }

    .success-file i {
        font-size: 25px;
        color: #1bad28;
    }

    .text-blue-2 {
        position: relative;
        top: 7px;
    }

        .text-blue-2 a {
            color: #12b8f6;
            font-size: 12px;
        }

    #qh li {
        float: left;
        width: 50%;
        height: 30px;
        text-align: center;
        line-height: 30px;
        font-size: 14px;
        font-weight: bold;
        background: #e8ebed;
        cursor: pointer;
    }

    .fx {
        margin-top: 20px;
    }

    #qh li.active {
        background: #12b8f6;
        color: #fff;
    }

    .qh {
        border: 1px solid #12b8f6;
        padding: 30px 20px;
    }

    .imageYL {
        cursor: zoom-in;
    }

    .folder-list {
        list-style: none;
        padding-left: 30px;
        font-size: 16px;
        -webkit-user-select: none; /* for Chrome */
        -moz-user-select: none; /* for Firefox */
        user-select: none;
    }

        .folder-list li {
            float: left;
            margin: 10px;
            padding: 10px;
        }


            .folder-list li:hover {
                background-color: #12b8f6;
                border-radius: 2px;
                COLOR: #f5f5f5;
            }

    .foldersel {
        background-color: #f5f5f5;
    }
</style>
<script src="/ViewV5/JS/timego.js"></script>

<div ms-controller="APP_QYWDGX">

    <div class="padding20" style="display: none">
        <div class="btn-add">
            <button type="button" class="btn btn-info" ms-click="downloaditem()"><i class="iconfont icon-xiazai ft12 mr5"></i>下载</button>
        </div>
        <div class="input-group" style="width: 295px;">
            <input type="search" class="form-control" placeholder="输入文件名或后缀搜索" ms-duplex="searchContent">
            <span class="input-group-addon" ms-click="getSearchFile()">搜索</span>
        </div>
    </div>
    <div>
        <ol class="breadcrumb">
            <li ms-click="model.refpage('')"><a class="text-primary">共享文件</a></li>
            <li ms-click="SelectLYType(seluser)"><a class="text-primary">{{ComFunJS.convertuser(seluser)}}</a></li>
            <li ms-repeat-path="Pathdata" ms-class="active:path.active" ms-click="gopath(path)"><a ms-class="text-primary:!path.active">{{path.Name}}</a></li>
        </ol>
    </div>
    <div id="tab">
        <div ms-if="showtype=='0'">
            <ul style="padding-left: 10px;" class="folder-list">
                <li ms-repeat-el="gxlydata" ms-click="SelectLYType(el.CRUser)">
                    <div style="text-align: center">
                        <img src="/ViewV5/images/qywd/file1.png" class="img70 mr5">
                    </div>
                    <div style="text-align: center; margin-top: 10px">
                        <span class="spanwz">{{el.UserRealName}}</span>

                    </div>

                </li>

            </ul>
        </div>

        <div class="default-tab ft14" ms-if="showtype=='1'">
            <table class="table table-hover">
                <caption style="padding-left: 12px; color: cornflowerblue">
                    已选中{{tempindex.SelItemData.size()}}
                    <button type="button" class="btn btn-info" ms-click="downloaditem()" style="margin-left: 5PX"><i class="iconfont icon-xiazai ft12 mr5"></i>下载</button>
                </caption>
                <thead>

                    <tr>
                        <th style="width: 40px; padding-left: 12px">
                            <div class="icheckbox_square-blue" ms-click="selallItems($(this))">
                                <span class="iconfont icon-check ft12"></span>
                            </div>
                        </th>
                        <th>文件名</th>
                        <th style="width: 120px;"></th>
                        <th style="width: 40px;"></th>
                        <th style="width: 100px;">大小</th>
                        <th style="width: 80px;">格式</th>
                        <th style="width: 160px;">创建时间</th>
                    </tr>
                </thead>
                <tbody class="wdlist">

                    <tr ms-repeat-folder="FolderList" ms-on-mousedown="filecontextmenu(folder,$event)" data-repeat-rendered="filechange">
                        <td class="tc">
                            <div class="icheckbox_square-blue" ms-click="selItems(folder,$event)" ms-class-1="checked:folder.issel">
                                <span class="iconfont icon-check ft12"></span>
                            </div>
                        </td>
                        <td ms-click="enterFolder(folder,$event)" class="trdata">
                            <div>
                                <img src="/ViewV5/images/qywd/file1.png" class="img40 mr5">
                                {{folder.Name}}
                            </div>
                        </td>
                        <td class="tc"></td>
                        <td class="tc"></td>
                        <td></td>
                        <td></td>
                        <td>{{folder.CRDate}}</td>
                    </tr>
                    <tr ms-repeat-file="FileList" ms-on-mousedown="filecontextmenu(file,$event)" data-repeat-rendered="filechange" class="trdata">
                        <td class="tc" style="width: 40px;">
                            <div class="icheckbox_square-blue" ms-click="selItems(file,$event)" ms-class-1="checked:file.issel">
                                <span class="iconfont icon-check ft12"></span>
                            </div>
                        </td>
                        <td>
                            <div>
                                <img ms-attr-filename="file.name" ms-attr-src="getsrc(file)" ms-click="viewitem(file)" ms-attr-imgyt="{{ComFunJS.getfile(file.ID)}}" ms-class-1="imageYL:ComFunJS.isPic(file.FileExtendName)" class="img40 mr5" onerror="javascript: this.src = '/ViewV5/images/qywd/file.png'">{{file.Name}}

                            </div>
                        </td>
                        <td class="tc"><a class="btn btn-link" ms-if="(file.ISYL&&file.YLUrl)||file.FileExtendName=='mp4'" ms-click="viewitem(file)">{{file.FileExtendName=="mp4"?"播放":"预览"}}</a></td>
                        <td class="tc"></td>
                        <td>{{ComFunJS.converfilesize(file.FileSize)}}</td>
                        <td>{{file.FileExtendName}}</td>
                        <td>{{file.CRDate}}</td>
                    </tr>

                </tbody>
            </table>
            <p class="tr c999 ft14" style="padding-right: 30px;">包含{{FileList.size()*1+FolderList.size()*1}}条</p>
            <div id="context-menu" class="conMenu">
                <ul class="dropdown-menu" role="menu">
                    <li ms-click="downloaditem"><a href="javascript:void(0)">&nbsp;&nbsp;下载</a></li>
                </ul>
            </div>
        </div>
    </div>



</div>
<script src="/ViewV5/JS/contextmenu.js"></script>
<script>
    var tempindex = avalon.define({
        $id: "APP_QYWDGX",
        name: "文档中心",
        itemtype: "4",//共享文档
        showtype: "0",
        seluser: "",//共享来源
        InitWigetData: function (para) {
            $.getJSON('/api/Bll/ExeAction?Action=QYWD_GETNBGXLY', {
            }, function (resultData) {//P1为个人文件夹
                tempindex.gxlydata = resultData.Result;
            })
        },
        Pathdata: [],
        gxlydata: [],
        SelectLYType: function (username) {
            tempindex.Pathdata.clear();
            tempindex.showtype = "1";
            $.getJSON('/api/Bll/ExeAction?Action=QYWD_GETNBSHARELIST', {
                P1: username
            }, function (resultData) {//P1为个人文件夹
                resultData.Result.forEach(function (item) {
                    item.issel = false;
                    item.type = "folder";
                })
                resultData.Result1.forEach(function (item) {
                    item.issel = false;
                    item.type = "file";
                })
                tempindex.FolderList = resultData.Result;
                tempindex.FileList = resultData.Result1;
                tempindex.seluser = username;
                tempindex.Pathdata.splice(1, tempindex.Pathdata.length - 1)
            })

        },
        getsrc: function (item) {//图片真实路径
            if (item.type == 'folder') {
                return " /ViewV5/images/qywd/file1.png";
            } else {
                if (ComFunJS.isPic(item.FileExtendName)) {
                    return ComFunJS.getfile(item.ID) + "&width=40&height=40";
                }
                else {
                    return " /ViewV5/images/qywd/" + item.FileExtendName + ".png";
                }
            }

        },
        gopath: function (path) {
            tempindex.SelItemData.clear();//清除选择项
            $(".icheckbox_square-blue").removeClass("checked")//清除所有样式
            tempindex.GetListData(path.ID);
            for (i = tempindex.Pathdata.size() - 1; i >= 0; i--) {
                if (tempindex.Pathdata[i].ID != path.ID) {
                    tempindex.Pathdata.pop(tempindex.Pathdata[i])
                } else {
                    tempindex.Pathdata[i].active = true;
                    return;
                }
            }

        },//目录链接
        FolderList: [],
        FileList: [],
        GetListData: function (PID) {
            $.getJSON('/api/Bll/ExeAction?Action=QYWD_GETLISTDATA', {
                P1: PID, itemtype: tempindex.itemtype
            }, function (resultData) {//P1为个人文件夹
                if (resultData.ErrorMsg == "") {
                    resultData.Result.forEach(function (item) {
                        item.issel = false;
                        item.type = "folder";
                    })
                    resultData.Result1.forEach(function (item) {
                        item.issel = false;
                        item.type = "file";

                    })
                    tempindex.FolderList = resultData.Result;
                    tempindex.FileList = resultData.Result1;
                }
            })
        },
        selallItems: function ($dom) {

            tempindex.SelItemData.clear();
            var issel = $dom.hasClass("checked");
            tempindex.FileList.forEach(function (item) {
                item.issel = !issel;
                if (!issel) {
                    tempindex.SelItemData.push(item.$model)
                } else {
                    ComFunJS.DelItem(tempindex.SelItemData, "ID", item.ID)
                }
            })//文件
            tempindex.FolderList.forEach(function (item) {
                item.issel = !issel;
                if (!issel) {
                    tempindex.SelItemData.push(item.$model)
                } else {
                    ComFunJS.DelItem(tempindex.SelItemData, "ID", item.ID)
                }
            })//文件夹
        },//全选
        selItems: function (item, event) {
            item.issel = !item.issel;
            if (item.issel) {
                tempindex.SelItemData.push(item.$model)
            } else {
                ComFunJS.DelItem(tempindex.SelItemData, "ID", item.ID)
            }
            event.stopPropagation();
        },//多选
        selItem: function (item, event) {
            tempindex.ListData.forEach(function (el) {
                el.issel = item.ID == el.ID;
            })
            tempindex.SelItemData.clear();
            tempindex.SelItemData.push(item.$model)
            event.stopPropagation();

        },//单选
        SelItemData: [],//已选中列表
        getselitem: function () {
            var Ids = "";
            $("tbody .checked").each(function () {
                Ids += $(this).prop("id") + ",";
            })
            Ids = Ids.length > 1 ? Ids.substring(0, Ids.length - 1) : Ids;
            return Ids;
        },
        enterFolder: function (folder) {
            tempindex.SelItemData.clear();//清除选择项
            var newpath = folder.$model;
            tempindex.Pathdata.forEach(function (path) {
                path.active = false;
            })
            newpath.active = true;
            tempindex.Pathdata.push(newpath);
            tempindex.GetListData(folder.ID);


        },//进入文件夹
        viewitem: function (item) {
            if (ComFunJS.isPic(item.FileExtendName)) { //如果是图片格式，显示图片
                ComFunJS.viewbigimg(this, ".imageYL")
                return;
            }
            if (item.FileExtendName.toLowerCase() == "mp4") {
                top.layer.open({
                    type: 2,
                    fix: true, //不固定
                    area: ['700px', '500px'],
                    maxmin: false,
                    content: "/ViewV5/Base/showvideo.html?md5=" + item.FileMD5,
                    title: "",
                    shadeClose: false, //加上边框
                    scrollbar: false,
                    shade: 0.4,
                    shift: 0
                });
            }
            if (ComFunJS.isOffice(item.FileExtendName)) {
                window.open(item.YLUrl)
            }

        },//查看文件
        filecontextmenu: function (item, event) {
            if (event.button == "2") {
                tempindex.FolderList.forEach(function (el) {
                    el.issel = item.ID == el.ID;
                })
                tempindex.FileList.forEach(function (el) {
                    el.issel = item.ID == el.ID;
                })
                tempindex.SelItemData.clear();
                tempindex.SelItemData.push(item.$model)
            }
        },//右键单选
        filechange: function (action) {
            if (action === "add" || action === "del" || action === "set") {
                $(".wdlist").find(".trdata").contextmenu({
                    target: '#context-menu',
                    before: function (e, context) {
                        // 隐藏其它右键菜单
                        $("#context-menu1").hide();
                        return true;
                    }
                });
            }
        },//数据更新后需要重新加载右键菜单
        downloaditem: function () {
            if (tempindex.SelItemData.size() == 0) {
                ComFunJS.winwarning("请选择文件再下载");
                return;
            }
            if (tempindex.SelItemData.size() == 1 && tempindex.SelItemData[0].type == "file") {
                location.href = ComFunJS.getfile(tempindex.SelItemData[0].ID);
            } else {
                var code = "";
                tempindex.SelItemData.forEach(function (item) {
                    code = code + item.ID + "|" + item.type + ",";
                })
                if (code.length > 1) {
                    code = code.substring(0, code.length - 1)
                }
                top.ComFunJS.winviewform("/ViewV5/AppPage/QYWD/DownFolder.html?code=" + code, "下载文件", "550", "450")
            }
        },//下载文件
        searchContent: "",
        getSearchFile: function () {
            tempindex.FileList.clear();
            tempindex.FolderList.clear();
            tempindex.SelItemData.clear();
            if (tempindex.searchContent) {
                $.getJSON('/api/Bll/ExeAction?Action=QYWD_QUERYFILE', {
                    P1: tempindex.itemtype, P2: tempindex.searchContent
                }, function (resultData) {//P1为个人文件夹
                    if (resultData.ErrorMsg == "") {
                        if (resultData.Result) {
                            resultData.Result.forEach(function (item) {
                                item.issel = false;
                                item.type = "file";

                            })
                            tempindex.FileList = resultData.Result;
                        }
                    }
                })
            } else {
                tempindex.GetListData(tempindex.itemtype);
            }
        }
    });//# sourceURL=APP_QYWDGX.js;


</script>
